import request from "@/utils/request";

// 获取员工列表数据
export const getEmployeeList = (params) => {
  return request({
    url: "/sys/user",
    method: 'get',
    params
  })
}

// 导出员工excel
export const exportEmployee = () => {
  return request({
    url: "/sys/user/export",
    responseType: 'blob' // 将响应结果的数据类型设置为二进制流（blob）
  })
}

// 下载员工导入模板
export const downloadTemplate = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}

// 导入员工excel
export const importEmployee = (data) => {
  return request({
    url: '/sys/user/import',
    method: 'post',
    data
  })
}

// 删除员工
export const deleteEmployee = (id) => {
  return request({
    url: `/sys/user/${id}`,
    method: 'delete'
  })
}

// 添加员工
export const addEmployee =(data) => {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}

// 获取员工详情
export const getEmployeeDetail = (id) => {
  return request({
    url: `/sys/user/${id}`
  })
}

// 编辑员工
export const editEmpolyee = (data) => {
  return request({
    url: `/sys/user/${data.id}`,
    method: "put",
    data
  })
}

// 获取所有启用的角色列表
export const getEnabledRoleList = () => {
  return request({
    url: '/sys/role/list/enabled'
  })
}

// 给员工分配角色
export const assignRole = (data) => {
  return request({
    url : '/sys/user/assignRoles',
    method: 'put',
    data
  })
}